Find pairs with given sum in doubly linked Leetcode